\rcube_image

Image resizer and converter

Summary

Methods
Properties
Constants
__construct()
props()
resize()
convert()
is_convertable()
$extensions
TYPE_GIF
TYPE_JPG
TYPE_PNG
TYPE_TIF
No protected methods found
No protected properties found
N/A
identify()
mem_check()
getCommand()
$image_file
N/A

Constants

TYPE_GIF

TYPE_GIF = 1

TYPE_JPG

TYPE_JPG = 2

TYPE_PNG

TYPE_PNG = 3

TYPE_TIF

TYPE_TIF = 4

Properties

$extensions

$extensions : array

Type

array — Image file type to extension map

$image_file

$image_file : string

Type

string — Image file location

Methods

__construct()

__construct(string  $filename) : mixed

Class constructor

Parameters

string $filename

Image file name/path

Returns

mixed —

props()

props() : array|null

Get image properties.

Returns

array|null —

Hash array with image props like type, width, height

resize()

resize(int  $size, string  $filename = null, bool  $browser_compat = false) : string|false

Resize image to a given size. Use only to shrink an image.

If an image is smaller than specified size it will be not resized.

Parameters

int $size

Max width/height size

string $filename

Output filename

bool $browser_compat

Convert to image type displayable by any browser

Returns

string|false —

Output type on success, False on failure

convert()

convert(int  $type, string  $filename = null) : bool

Convert image to a given type

Parameters

int $type

Destination file type (see class constants)

string $filename

Output filename (if empty, original file will be used and filename extension will be modified)

Returns

bool —

True on success, False on failure

is_convertable()

is_convertable(string  $mimetype = null) : bool

Checks if image format conversion is supported (for specified mimetype).

Parameters

string $mimetype

Mimetype name

Returns

bool —

True if specified format can be converted to another format

identify()

identify() : mixed

ImageMagick based image properties read.

Returns

mixed —

mem_check()

mem_check(mixed  $props) : bool

Check if we have enough memory to load specified image

Parameters

mixed $props

Returns

bool —

True if there's enough memory to process the image, False otherwise

getCommand()

getCommand(string  $opt_name) : bool|string

Get the configured command and make sure it is safe to use.

We cannot trust configuration, and escapeshellcmd() is useless.

Parameters

string $opt_name

Configuration option name

Returns

bool|string —

The command or False if not set or invalid